//-----------------------------------------------------------------------
// <copyright file="ShippingLineService.cs" company="Pyramid Consulting">
//     Copyright (c) Pyramid Consulting. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using MyFramework;
using MIMS.WRS.Entities;
using MIMS.WRS.Data;
    
namespace MIMS.WRS.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class ShippingLineService
    {
        #region ShippingLine

        public static void CreateShippingLine(ShippingLine shippingLine)
        {            
            try
            {
                ShippingLineDAO shippingLineDAO = new ShippingLineDAO();
                shippingLineDAO.CreateShippingLine(shippingLine);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateShippingLineException, ex);
            }
        }        

        public static void UpdateShippingLine(ShippingLine shippingLine)
        {            
            try
            {
                ShippingLineDAO shippingLineDAO = new ShippingLineDAO();
                shippingLineDAO.UpdateShippingLine(shippingLine);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateShippingLineException, ex);
            }
        }        

        public static void DeleteShippingLine(int id)
        {            
            try
            {
                ShippingLineDAO shippingLineDAO = new ShippingLineDAO();
                shippingLineDAO.DeleteShippingLine(id);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteShippingLineException, ex);
            }
        }
        
        public static ShippingLine GetShippingLine(int id)
        {            
            try
            {
                ShippingLineDAO shippingLineDAO = new ShippingLineDAO();
                return shippingLineDAO.GetShippingLine(id);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetShippingLineException, ex);
            }
        }                

        public static ShippingLineCollection GetShippingLines(ShippingLineColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                ShippingLineDAO shippingLineDAO = new ShippingLineDAO();
                return shippingLineDAO.GetShippingLines(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetShippingLinesException, ex);
            }
        }        

        public static ShippingLineCollection GetShippingLines(ShippingLineColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                ShippingLineDAO shippingLineDAO = new ShippingLineDAO();
                return shippingLineDAO.GetShippingLines(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetShippingLinesException, ex);
            }
        }        

        #endregion

		public static ShippingLine GetShippingLineByCode(string code)
		{            
			try
			{
				ShippingLineDAO shippingLineDAO = new ShippingLineDAO();
				return shippingLineDAO.GetShippingLineByCode(code);                
			}
			catch (BusinessException)
			{
				throw;
			}
			catch (Exception ex)
			{
				// log this exception
				Logger.Error(ex);
				// wrap it and rethrow
				throw new BusinessException(SR.BusinessGetShippingLineException, ex);
			}
		}      
    }
}